'use strict';
const dayjs = require("dayjs");
module.exports = app => {
    const { STRING, INTEGER,DATE } = app.Sequelize;
    return app.model.define(
        'disease',
        {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            beef: { type: INTEGER, allowNull: false, comment: '牛只' },
            symptom: { type: STRING(500), allowNull: true, comment: '症状' },
            startdate: {
                type: DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('startdate')).format('YYYY-MM-DD');
                }
            },
            enddate: {
                type: DATE,
                allowNull: true,
                get() {
                    return dayjs(this.getDataValue('enddate')).format('YYYY-MM-DD');
                }
            },
            distype: { type: STRING(50), allowNull: true, comment: '疾病类型' },
            disname: { type: STRING(50), allowNull: true, comment: '疾病名' },
            reason: { type: STRING(400), allowNull: true, comment: '发病原因' },
            healmeth: { type: STRING(400), allowNull: true, comment: '治疗方法' },
            status: { type: STRING(20), allowNull: true, comment: '状态' },
            healer: { type: STRING(20), allowNull: true, comment: '治疗人，兽医' },
            remark: { type: STRING(200), allowNull: true, comment: '备注' },
            version: { type: INTEGER, allowNull: false, defaultValue: 1 },
            is_deleted: { type: INTEGER, allowNull: false, defaultValue: 0 },
        },
        {
            tableName: 'disease',
            timestamps: true, // 启用时间戳(createdAt, updatedAt)
            updatedAt: false, // 不想要 updatedAt
            createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
        }
    );
};

